package Eric.Info;

import android.app.Notification;
import android.os.Bundle;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

class Catcher extends NotificationListenerService {
    @Override
    public void onListenerConnected() {
        super.onListenerConnected();
    }

    @Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        getNotifyData(sbn);
    }

    @Override
    public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
        getNotifyData(sbn);
    }

    @Override
    public void onNotificationRemoved(StatusBarNotification sbn) {

    }

    @Override
    public void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap) {
        super.onNotificationRemoved(sbn, rankingMap);
    }

    @Override
    public void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap, int reason) {
        super.onNotificationRemoved(sbn, rankingMap, reason);
    }

    private void getNotifyData(StatusBarNotification sbn){
        try {
            Bundle extras = sbn.getNotification().extras;
            String content = "";
            String title = extras.getString(Notification.EXTRA_TITLE,""); //通知标题
            content = extras.getString(Notification.EXTRA_TEXT,"");//通知内容

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}